home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / librw / RWCacheManager.z / RWCacheManager
Encoding:
Text File  |  2002-10-03  |  5.4 KB  |  133 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr((((3333CCCC++++++++))))                                      RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWCacheManager - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/cacheman.h>
  13.  
  14.  
  15.  
  16.               RWFile f("file.dat");       // Construct a file
  17.           RWCacheManager(&f, 100);    // Cache 100 byte blocks to file.dat
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr caches fixed length blocks to and from an associated
  24.      RRRRWWWWFFFFiiiilllleeee.  The block size can be of any length and is set at construction
  25.      time.  The number of cached blocks can also be set at construction time.
  26.      Writes to the file may be deferred.  Use member function fffflllluuuusssshhhh(((()))) to have
  27.      any pending writes performed.
  28.  
  29. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee
  30.      None
  31.  
  32. EEEExxxxaaaammmmpppplllleeee
  33.               #include <rw/cacheman.h>
  34.           #include <rw/rwfile.h>
  35.           struct Record {
  36.             int i;
  37.             float f;
  38.             char str[15];
  39.           };
  40.           main(){
  41.              RWoffset loc;
  42.              RWFile file("file.dat");     // Construct a file
  43.              // Construct a cache, using 20 slots for struct Record:
  44.                 RWCacheManager cache(&file, sizeof(Record), 20);
  45.              Record r;
  46.              // ...
  47.              cache.write(loc, &r);
  48.              // ...
  49.              cache.read(loc, &r);
  50.           }
  51.  
  52. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrr
  53.               RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr(RWFile* file, unsigned blocksz,
  54.                          unsigned mxblks = 10);
  55.  
  56.  
  57.      Construct a cache for the RRRRWWWWFFFFiiiilllleeee pointed to by ffffiiiilllleeee.  The length of the
  58.      fixed-size blocks is given by bbbblllloooocccckkkksssszzzz.  The number of cached blocks is
  59.      given by mmmmxxxxbbbbllllkkkkssss.  If the total number of bytes cached would exceed the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr((((3333CCCC++++++++))))                                      RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74.      maximum value of an unsigned int, then RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr will quietly decide
  75.      to cache a smaller number of blocks.
  76.  
  77. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  78.               ~RRRRWWWWCCCCaaaacccchhhheeeeMMMMaaaannnnaaaaggggeeeerrrr();
  79.  
  80.  
  81.      Performs any pending I/O operations (iiii....eeee...., calls fffflllluuuusssshhhh(((())))) and deallocates
  82.      any allocated memory.
  83.  
  84. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  85.               RWBoolean
  86.           fffflllluuuusssshhhh();
  87.  
  88.  
  89.      Perform any pending I/O operations.  Returns TTTTRRRRUUUUEEEE if the flush was
  90.      successful, FFFFAAAALLLLSSSSEEEE otherwise.
  91.  
  92.               void
  93.           iiiinnnnvvvvaaaalllliiiiddddaaaatttteeee();
  94.  
  95.  
  96.      Invalidate the cache.
  97.  
  98.               RWBoolean
  99.           rrrreeeeaaaadddd(RWoffset locn, void* dat);
  100.  
  101.  
  102.      Return the data located at offset llllooooccccnnnn of the associated RRRRWWWWFFFFiiiilllleeee.  The
  103.      data is put in the buffer pointed to by ddddaaaatttt.  This buffer must be at
  104.      least as long as the block size specified when the cache was constructed.
  105.      Returns TTTTRRRRUUUUEEEE if the operation was successful, otherwise FFFFAAAALLLLSSSSEEEE.
  106.  
  107.               RWBoolean
  108.           wwwwrrrriiiitttteeee(RWoffset locn, void* dat);
  109.  
  110.  
  111.      Write the block of data pointed to by ddddaaaatttt to the offset llllooooccccnnnn of the
  112.      associated RRRRWWWWFFFFiiiilllleeee.  The number of bytes written is given by the block
  113.      size specified when the cache was constructed.  The actual write to disk
  114.      may be deferred.  Use member function fffflllluuuusssshhhh(((()))) to perform any pending
  115.      output.  Returns TTTTRRRRUUUUEEEE if the operation was successful, otherwise FFFFAAAALLLLSSSSEEEE.
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.